package com.qef.com.mmovie.activity

import android.animation.Animator
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.ActivityOptionsCompat
import android.support.v7.app.AppCompatActivity
import android.widget.ImageView
import com.qef.com.mmovie.MainActivity
import com.qef.com.mmovie.R
import com.qef.com.mmovie.utils.HindToolbar
import kotlinx.android.synthetic.main.activity_wellcome.*
import com.umeng.analytics.MobclickAgent


class WellcomeActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        HindToolbar.setHintWindowTitle(window)
        setContentView(R.layout.activity_wellcome)
        initView()
    }

    private fun initView() {
        val bg_image: ImageView = bg_image
        val animatorSet = AnimatorSet()
        val animator = ObjectAnimator.ofFloat(bg_image, "scaleX", 1.0f, 1.1f)
        val animator1 = ObjectAnimator.ofFloat(bg_image, "scaleY", 1f, 1.1f)
        animatorSet.playTogether(animator, animator1)
        animatorSet.setDuration(2000).start()
        animatorSet.addListener(object : Animator.AnimatorListener {
            override fun onAnimationRepeat(p0: Animator?) {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }

            override fun onAnimationCancel(p0: Animator?) {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }

            override fun onAnimationStart(p0: Animator?) {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }

            override fun onAnimationEnd(p0: Animator?) {
                val compat = ActivityOptionsCompat.makeSceneTransitionAnimation(this@WellcomeActivity)
                startActivity(Intent(this@WellcomeActivity, MainActivity::class.java), compat.toBundle())
//                        UIHelper . goMainActivity (this@WellcomeActivity)
                this@WellcomeActivity.finish()
            }
        })
    }

    public override fun onResume() {
        super.onResume()
        MobclickAgent.onResume(this)
    }

    public override fun onPause() {
        super.onPause()
        MobclickAgent.onPause(this)
    }
}
